
Page({

	data: {
		nowDate: '2022-12-25 9:00:00', //结束时间
    countdown: '', //倒计时
    days: '00', //天
    hours: '00', //时
    minutes: '00', //分
    seconds: '00', //秒
    
    //搜索
    values:"",
    
    
    slider: [
      {
        id:0,
        linkUrl:"武汉纺织大学",
        picUrl:"https://s1.ax1x.com/2022/04/15/LGDznA.jpg",
      },
      {
        id:1,
        linkUrl:"",
        picUrl:"https://s1.ax1x.com/2022/04/15/LG0f4U.jpg",
      },
      {
        id:2,
        linkUrl:"",
        picUrl:"https://s1.ax1x.com/2022/04/15/LGDvXd.jpg",
      },
      {
        id:3,
        linkUrl:"",
        picUrl:"https://s1.ax1x.com/2022/04/15/LGrS0I.jpg",
      },
      {
        id:4,
        linkUrl:"",
        picUrl:"https://s1.ax1x.com/2022/04/15/LGDvXd.jpg",
      },

    ], 
    swiperCurrent: 0,
  },

  share(e){
    wx.downloadFile({
      url: e.currentTarget.dataset.url,
      success: (res) => {
        wx.showShareImageMenu({
          path: res.tempFilePath
        })
        
      },
      fail: (res) => {
        
      },
    })
  },

  
  goNews:function(e){
    var vv=e.detail.value;
    //comment
    this.setData({
      values:vv,
    })
    //console.log(this.data.values);
    
  },

  goPig: function () {
    wx.navigateTo({
      url: '/pages/index/news/news',
    })
  },

  
  suo: function () {
    console.log(this.data.values);
    wx.navigateTo({
      url: '/pages/index/news/news?va='+this.data.values,
    })
  },
  

	
 countTime() {
    let days,hours, minutes, seconds;
    let nowDate = this.data.nowDate;
    console.log(nowDate)
    let that = this;
    let now = new Date().getTime();
    let end = new Date(nowDate).getTime(); //设置截止时间
    // console.log("开始时间：" + now, "截止时间:" + end);
    let leftTime = end - now; //时间差                         
    if (leftTime >= 0) {
      days = Math.floor(leftTime / 1000 / 60 / 60 / 24);
      hours = Math.floor(leftTime / 1000 / 60 / 60 % 24);
      minutes = Math.floor(leftTime / 1000 / 60 % 60);
      seconds = Math.floor(leftTime / 1000 % 60);
      seconds = seconds < 10 ? "0" + seconds : seconds
      minutes = minutes < 10 ? "0" + minutes : minutes
      hours = hours < 10 ? "0" + hours : hours
      that.setData({
        countdown: days+":"+hours + "：" + minutes + "：" + seconds,
        days,
        hours,
        minutes,
        seconds
      })
      // console.log(that.data.countdown)
      //递归每秒调用countTime方法，显示动态时间效果
      setTimeout(that.countTime, 1000);
    } else {
      that.setData({
        countdown: '已截止'
      })
    }
 },

 goUrl(){
   wx.navigateTo({
     url: './news/news',
   })
 },

 goCourse(e){
   let cc=e.currentTarget.dataset.id;
  wx.navigateTo({
    url: './course/course?zz='+cc,
  })
},

goMath(){
  wx.navigateTo({
    url: './math/math',
  })
},

goEnglish(){
  wx.navigateTo({
    url: './english/english',
  })
},

goMore(){
  wx.navigateTo({
    url: './more/more',
  })
},


 onLoad: function (options) {
    this.countTime();

    // var that = this; 
    // //网络访问，获取轮播图的图片 
    //   util.getRecommend(function(data){ 
    //     that.setData({ 
    //       slider: data.data.slider 
    //     }) 
    //   });  
}, 
    //轮播图的切换事件 
    swiperChange: function(e){ 
    //只要把切换后当前的index传给<swiper>组件的current属性即可 
      this.setData({ 
      swiperCurrent: e.detail.current 
      }) 
    }, 
    //点击指示点切换 
    chuangEvent: function(e){ 
      this.setData({ 
        swiperCurrent: e.currentTarget.id 
    }) 
    },
})

